/**
 * 初始声明调用方法
 */
$.fn.zTreeSelect = function (setting, zNodes, open) {
	var contactor = $(this);
	if ($(this).length > 0) {
		for (var i = 0; i < $(this).length; i++) {
			contactor = $($(this)[i]).hasClass("zTreeSelect-text") ? $($(this)[i]) : $(contactor).parent(".zTreeSelect").find(".zTreeSelect-text");//文本框
			if ($($(this)[i]).hasClass("zTreeSelect-arrow")) {
				$($(this)[i]).unbind("click").bind("click",function(){
					$(contactor).click();check
				});
			}
		}
	}
	zTreeSelectConfig(contactor);//配置属性及元素
	zTreeSelectInit(contactor, setting, zNodes, open);//初始化变量值
	
	$(contactor).unbind().click(function () {
		if ($(contactor).parent(".zTreeSelect").next(".zTreeSelect-menuContent").length > 0) {
			hideMenu(contactor);//隐藏树形结构
		} else {
			loadTreeDemo(contactor, setting, zNodes, open);//加载树型结构
			showMenu(contactor);//打开树形结构
		}
	});
};

$.fn.zTreeSelectClear = function () {
	var contactor = $(this);
	if ($(this).length > 0) {
		for (var i = 0; i < $(this).length; i++) {
			contactor = $($(this)[i]).hasClass("zTreeSelect-text") ? $($(this)[i]) : $(contactor).parent(".zTreeSelect").find(".zTreeSelect-text");//文本框
		}
	}
	$(contactor).val("").attr("tIdsCut","");
	$(contactor).siblings(".zTreeSelect-hidden").val("");
};

/**
 * 配置属性及元素
 * @param contactor 触发的元素对象
 */
function zTreeSelectConfig(contactor) {
	var zTreeSelect = $(contactor).parent(".zTreeSelect");//外围父级容器
	var zTreeSelectFields = $(zTreeSelect).attr("zTreeSelect-fields");//自定义动态查询字段
	
	$(zTreeSelect).find(".zTreeSelect-text").css({
		width : ($(zTreeSelect).width() - 27) + "px"
	});
	//动态创建要查询的字段隐藏域
	if (typeof(zTreeSelectFields) != "undefined" && zTreeSelectFields != "") {
		var fields = zTreeSelectFields.split(",");
		for (var i = 0; i < fields.length; i++) {
			$(zTreeSelect).append('<input type="hidden" class="zTreeSelect-'+fields[i]+'-hidden" value=""/>');
		}
	}
	//加载选中的唯一标识链属性
	if (typeof($(zTreeSelect).find(".zTreeSelect-text").attr("tIdsCut")) == "undefined") {
		$(zTreeSelect).find(".zTreeSelect-text").attr("tIdsCut","");
	}
}

/**
 * 初始化变量值
 * @param contactor 触发的元素对象
 * @param setting 树控件配置参数
 * @param zNodes 树控件结构参数
 */
function zTreeSelectInit(contactor, setting, zNodes, open) {
	var id = $(contactor)[0].id;
	
	var zTreeSelect = $(contactor).parent(".zTreeSelect");//外围父级容器
	var zTreeSelectFields = $(zTreeSelect).attr("zTreeSelect-fields");//自定义动态查询字段
	var zTreeSelectText = $(contactor).hasClass("zTreeSelect-text") ? $(contactor) : $(contactor).siblings(".zTreeSelect-text");//文本框
	var zTreeSelectTextField = $(zTreeSelectText).attr("zTreeSelect-text-field");//文本框填充的字段变量
	zTreeSelectTextField = (typeof(zTreeSelectTextField) != "undefined" && zTreeSelectTextField != "") ? zTreeSelectTextField : "name";//文本框填充的字段变量
	var zTreeSelectHidden = $(contactor).siblings(".zTreeSelect-hidden");
	var zTreeSelectIdField = $(zTreeSelectHidden).attr("zTreeSelect-id-field");
	zTreeSelectIdField = (typeof(zTreeSelectIdField) != "undefined" && zTreeSelectIdField != "") ? zTreeSelectIdField : "id";//唯一标识匹配的字段变量
	var zTreeSelectHiddenVal = $(zTreeSelectHidden).val();
	
	loadTreeDemo(contactor, setting, zNodes, open);//加载树型结构
	var treeObj = $.fn.zTree.getZTreeObj("treeDemo_" + id);
	
	var zTreeSelectTextVal = "",tIdsCut = "";
	var fields = zTreeSelectHiddenVal.split(",");
	for (var i = 0; i < fields.length; i++) {
		if ("" != fields[i]) {
			var node = treeObj.getNodeByParam(zTreeSelectIdField, fields[i], null);
			if (null == node) {
				continue;
			}
			zTreeSelectTextVal += zTreeSelectTextVal == "" ? node[zTreeSelectTextField] : "," + node[zTreeSelectTextField];//文本框值回填操作
			var tId = node["tId"];
			var tIdCut = getTIdCut(tId);
			tIdsCut += tIdsCut == "" ? tIdCut : "," + tIdCut;//唯一变量链回填操作
			
			//动态回填要查询的字段隐藏域
			if (typeof(zTreeSelectFields) != "undefined" && zTreeSelectFields != "") {
				var hiddenFields = zTreeSelectFields.split(",");
				for (var j = 0; j < hiddenFields.length; j++) {
					var hiddenField = hiddenFields[j];
					if ("" != hiddenField) {
						var objHiddenVal = $(contactor).siblings(".zTreeSelect-"+hiddenField+"-hidden").val();
						objHiddenVal = objHiddenVal == "" ? node[hiddenField] : objHiddenVal + "," + node[hiddenField];
						$(contactor).siblings(".zTreeSelect-"+hiddenField+"-hidden").val(objHiddenVal);
					}
				}
			}
		}
	}
	$(zTreeSelectText).val(zTreeSelectTextVal).attr("tIdsCut",tIdsCut);
	hideMenu(contactor);//隐藏树形结构
}

/**
 * 加载树型结构
 * @param contactor 触发的元素对象
 * @param setting 树控件配置参数
 * @param zNodes 树控件结构参数
 */
function loadTreeDemo(contactor, setting, zNodes, open) {
	var id = $(contactor)[0].id;
	if(typeof(id) != "undefined") {
		var zTreeSelectSearchField = $(contactor).parent(".zTreeSelect").attr("zTreeSelect-search-field");//判断是否有搜索框
		var zTreeSelectModal = '<div id="menuContent_'+ id +'" class="zTreeSelect-menuContent" style="display:none;">';
			if (typeof(zTreeSelectSearchField) != "undefined" && zTreeSelectSearchField != "") {
				zTreeSelectModal += '<input type="text" id="treeSearch_'+ id +'" class="zTreeSelect-menuSearch" placeholder="搜索" autocomplete="off"/>';
				zTreeSelectModal += '<div class="zTreeSelect-line"></div>';
			}
			zTreeSelectModal +=	'<ul id="treeDemo_'+ id +'" class="ztree scrollBox"></ul>';
			zTreeSelectModal += '</div>';
		$(contactor).parent(".zTreeSelect").after(zTreeSelectModal);
		if (typeof(zTreeSelectSearchField) != "undefined" && zTreeSelectSearchField != "") {
			$("#treeSearch_" + id).bind("propertychange", searchNode).bind("input", searchNode);
		}
		$.fn.zTree.init($("#treeDemo_" + id), setting, zNodes);
		
		if(typeof(open)=="number") {
			var treeObj = $.fn.zTree.getZTreeObj("treeDemo_" + id);
			for(var i = 0; i <= open; i++) {
				var nodes = treeObj.getNodesByParam("level", String(i), null);
				for(var j = 0; j < nodes.length; j++) {
					var node = nodes[j];
					treeObj.expandNode(node,true,false,false);
				}
			}
		} else if (typeof(open)=="boolean") {
			$.fn.zTree.getZTreeObj("treeDemo_" + id).expandAll(open);
		}
	}
}

/** 
 * 选中树checkbox/radio的时候给文本框赋值
 */
function zTreeOnCheck(e, treeId, treeNode) {
	zTreeSelectEvent(e, treeId, treeNode);

}


/**
 * 点击树的时候给文本框赋值
 */
function zTreeOnClick(e, treeId, treeNode) {
	var treeObj = $.fn.zTree.getZTreeObj(treeId);
	treeObj.checkNode(treeNode, !treeNode.checked, true);//点击中文同时选中前面的checkbox/radio
	zTreeSelectEvent(e, treeId, treeNode);
	
	var bindObjId = treeId.split("_")[1];
	var zTreeSelectTextSelectedHiddenEnable = $("#" + bindObjId).parent(".zTreeSelect").attr("zTreeSelect-textSelectedHidden-enable");//自定义动态查询字段
	if (typeof(zTreeSelectTextSelectedHiddenEnable) != "undefined" && (/^true$/i).test(zTreeSelectTextSelectedHiddenEnable)) {
		hideMenu($("#" + bindObjId));//隐藏树形结构
	}
    if (typeof(treeObj.setting.callback.onChange) != "undefined") {
        treeObj.setting.callback.onChange(bindObjId, $("#" + bindObjId).prev('.zTreeSelect-hidden').val(), $("#" + bindObjId).val());
    }
    hideMenu($("#" + bindObjId));

	//alert($("#" + bindObjId).prev('.zTreeSelect-hidden').val());
    //alert($("#" + bindObjId).val())

}

/***分配选择渠道****/
function zTreeClick(e, treeId, treeNode) {
    var treeObj = $.fn.zTree.getZTreeObj(treeId);
    treeObj.checkNode(treeNode,!treeNode.checked,true);//点击中文同时选中前面的checkbox/radio
    var nodes = treeObj.getCheckedNodes(true);
    zTreeSelectEvent(e, treeId, treeNode);

    v = "";
    for (var i = 0, l = nodes.length; i < l; i++) {
        v += nodes[i].name + ",";   //获取所选节点的名称
    }
    if (v.length > 0) v = v.substring(0, v.length - 1);
    var userId = $('#text');
    userId.attr("value", v);


    //将数值转换成html标签
    vHtml = "";
    for (var i = 0, l = nodes.length; i < l; i++) {
        vHtml += '<div class="box">'+nodes[i].name + '<i></i></div>';   //获取所选节点的名称
    }
    if (vHtml.length > 0) vHtml = vHtml.substring(0, vHtml.length - 1);
    $('#log').html(vHtml);
}

function zTreeCheck(e, treeId, treeNode) {
    zTreeSelectEvent(e, treeId, treeNode);
    var treeObj = $.fn.zTree.getZTreeObj(treeId);
    var nodes = treeObj.getCheckedNodes(true);
    vCheck = "";
    for (var i = 0, l = nodes.length; i < l; i++) {
        vCheck += nodes[i].name + ",";   //获取所选节点的名称

    }
    if (vCheck.length > 0) vCheck = vCheck.substring(0, vCheck.length - 1);
    var userId = $('#text');
    userId.attr("value", vCheck);

    //将数值转换成html标签
    vHtml = "";
    for (var i = 0, l = nodes.length; i < l; i++) {
        vHtml += '<div class="box">'+nodes[i].name + '<i></i></div>';   //获取所选节点的名称
    }
    if (vHtml.length > 0) vHtml = vHtml.substring(0, vHtml.length - 1);
    $('#log').html(vHtml);


}



/**
 * Table点击树的时候给文本框赋值
 */

function TablezTreeClick(e, treeId, treeNode) {
    var treeObj = $.fn.zTree.getZTreeObj(treeId);
    treeObj.checkNode(treeNode, !treeNode.checked, true);//点击中文同时选中前面的checkbox/radio
    var nodes = treeObj.getCheckedNodes(true);
    zTreeSelectEvent(e, treeId, treeNode);
    v = "";
    for (var i = 0, l = nodes.length; i < l; i++) {

        v += nodes[i].name + ",";   //获取所选节点的名称
        // if (!nodes[i].isParent) {       //isParent判断是否为父级，也就是是否有下级
        //v += nodes[i].name + ",";   //获取所选节点的名称
        // }
    }
    if (v.length > 0)
        v = v.substring(0, v.length - 1);
    var userId = $('#text');
    userId.attr("value", v);
}


/**
 * 截取节点唯一标识的下标
 * @param tId ztree节点的唯一标识
 * @returns
 */
function getTIdCut(tId) {
	if (tId.lastIndexOf("_") > -1) {
		return tId.substring(tId.lastIndexOf("_") + 1,tId.length);
	} else {
		return "";
	}
}



/** 
 * 点击树触发的事件
 */
function zTreeSelectEvent(e, treeId, treeNode) {
    var treeObj = $.fn.zTree.getZTreeObj(treeId);
    var nodes = treeObj.getCheckedNodes(true);
    var bindObjId = treeId.split("_")[1];
    var zTreeSelectFields = $("#" + bindObjId).parent(".zTreeSelect").attr("zTreeSelect-fields");//自定义动态查询字段
    var zTreeSelectHidden = $("#" + bindObjId).siblings(".zTreeSelect-hidden");//唯一变量隐藏域
    var zTreeSelectIdField = $(zTreeSelectHidden).attr("zTreeSelect-id-field");
    zTreeSelectIdField = (typeof(zTreeSelectIdField) != "undefined" && zTreeSelectIdField != "") ? zTreeSelectIdField : "id";//唯一标识匹配的字段变量
    var zTreeSelectText = $("#" + bindObjId).hasClass("zTreeSelect-text") ? $("#" + bindObjId) : $("#" + bindObjId).siblings(".zTreeSelect-text");//文本框
    var zTreeSelectTextField = $(zTreeSelectText).attr("zTreeSelect-text-field");//文本框填充的字段变量
    zTreeSelectTextField = (typeof(zTreeSelectTextField) != "undefined" && zTreeSelectTextField != "") ? zTreeSelectTextField : "name";//文本框填充的字段变量
    if (nodes.length > 0) {
        var zTreeSelectHiddenVal = "",tIdsCut = "";//唯一变量链回填操作
        var fieldsJson = {};//产生一个json数组变量，用来操作动态查询字段

        for (var i = 0; i < nodes.length; i++) {
            var tId = nodes[i].tId;
            var id = nodes[i][zTreeSelectIdField];
            var tIdCut = getTIdCut(tId);
            tIdsCut += tIdsCut == "" ? tIdCut : "," + tIdCut;//唯一变量链回填操作
            zTreeSelectHiddenVal += zTreeSelectHiddenVal == "" ? id : "," + id;

            //动态查询字段
            if (typeof(zTreeSelectFields) != "undefined" && zTreeSelectFields != "") {
                var fields = zTreeSelectFields.split(",");
                for (var j = 0; j < fields.length; j++) {
                    var fieldVal = typeof(fieldsJson[fields[j]]) == "undefined" ? "" : fieldsJson[fields[j]];
                    fieldVal += fieldVal == "" ? nodes[i][fields[j]] : "," + nodes[i][fields[j]];
                    fieldsJson[fields[j]] = fieldVal;
                }
            }
        }
        //动态查询字段，填充隐藏域
        if (typeof(zTreeSelectFields) != "undefined" && zTreeSelectFields != "") {
            var fields = zTreeSelectFields.split(",");
            for (var j = 0; j < fields.length; j++) {
                $("#" + bindObjId).siblings(".zTreeSelect-"+fields[j]+"-hidden").val(fieldsJson[fields[j]]);
            }
        }
        $(zTreeSelectText).attr("tIdsCut",tIdsCut);
        $(zTreeSelectHidden).val(zTreeSelectHiddenVal);//唯一变量链回填操作
        if (typeof($(zTreeSelectText).attr("zTreeSelect-text-ismember")) != "undefined" && (/^true$/i).test($(zTreeSelectText).attr("zTreeSelect-text-ismember"))) {
            $(zTreeSelectText).val($("#" + bindObjId).siblings(".zTreeSelect-"+zTreeSelectTextField+"-hidden").val());//文本框值回填操作
        } else {
            $(zTreeSelectText).val(treeNode[zTreeSelectTextField]);//文本框值回填操作
        }
    } else {
        var checkEnable = treeObj.setting.check.enable;
        if (checkEnable) {
            //动态查询字段，填充隐藏域
            if (typeof(zTreeSelectFields) != "undefined" && zTreeSelectFields != "") {
                var fields = zTreeSelectFields.split(",");
                for (var j = 0; j < fields.length; j++) {
                    $("#" + bindObjId).siblings(".zTreeSelect-"+fields[j]+"-hidden").val("");
                }
            }
            $(zTreeSelectText).attr("tIdsCut","").val("");//文本框值回填操作
            $(zTreeSelectHidden).val("");//唯一变量链回填操作
        } else {
            //动态查询字段，填充隐藏域
            if (typeof(zTreeSelectFields) != "undefined" && zTreeSelectFields != "") {
                var fields = zTreeSelectFields.split(",");
                for (var j = 0; j < fields.length; j++) {
                    $("#" + bindObjId).siblings(".zTreeSelect-"+fields[j]+"-hidden").val(treeNode[fields[j]]);
                }
            }
            var tId = treeNode.tId;
            var tIdCut = getTIdCut(tId);
            $(zTreeSelectText).attr("tIdsCut",tIdCut).val(treeNode[zTreeSelectTextField]);//文本框值回填操作
            $(zTreeSelectHidden).val(treeNode[zTreeSelectIdField]);//唯一变量链回填操作
        }
    }
    if (typeof(treeObj.setting.callback.onSelect) != "undefined") {
        treeObj.setting.callback.onSelect();
    }
}


/*搜索触发高亮显示*/
function getFontCss(treeId, treeNode) {
    return (!!treeNode.highlight) ? {"color":"#fff","background":"#fff3ef"} : {"color":"#333","background":"none"};
}






/**打开树形结构* */
function showMenu(contactor) {
	var id = $(contactor)[0].id;
	var treeObj = $.fn.zTree.getZTreeObj("treeDemo_" + id);
	var zTreeNodes = treeObj.transformToArray(treeObj.getNodes());//所有集合对象
	
	var zTreeSelectText = $(contactor).hasClass("zTreeSelect-text") ? $(contactor) : $(contactor).siblings(".zTreeSelect-text");
	var textObjOffset = $(zTreeSelectText).offset();
	
	$("#treeSearch_" + id).css({ width : ($(contactor).parent(".zTreeSelect").width() - 12) + "px" });
	var zTreeSelectPosition = $(contactor).parent(".zTreeSelect").attr("zTreeSelect-position");//设置下拉选择项是否要浮动
	var positionCss = "absolute", topCss = textObjOffset.top + zTreeSelectText.outerHeight + "px";
	if ((/^true$/i).test(zTreeSelectPosition)) {
		positionCss = "fixed";
		topCss = "auto";
	}
	$("#menuContent_" + id).css({
		width : $(contactor).parent(".zTreeSelect").width() + "px",
		position : positionCss,
		top : topCss,
		//left : (textObjOffset.left - 1) + "px"
	}).slideDown("fast",function(){
		$(document).bind("mousedown", onBodyDown);
		//操作选中回填
		var tIdsCut = $(zTreeSelectText).attr("tIdsCut");
		var tIdsCutArray = tIdsCut.split(",");
		for (var i = 0; i < tIdsCutArray.length; i++) {
			var selectedtIdCut = tIdsCutArray[i];
			for (var j = 0; j < zTreeNodes.length; j++) {
				var tId = zTreeNodes[j].tId;
				var tIdCut = getTIdCut(tId);
				if (selectedtIdCut == tIdCut) {
					treeObj.checkNode(zTreeNodes[j], true);
				}
			}
		}
	});
	$("#menuContent_" + id + " .ztree").css({ width : ($(contactor).parent(".zTreeSelect").width() - 12) + "px" });
	$(contactor).parent(".zTreeSelect").find(".zTreeSelect-arrow").removeClass("arrow-down").addClass("arrow-up");
}

/** 
 * 隐藏树形结构
 */
function hideMenu(contactor) {
	if (typeof(contactor) != "undefined" && contactor != "") {
		var id = $(contactor)[0].id;
		$.fn.zTree.destroy("treeDemo_" + id);//销毁树结构
		$("#menuContent_" + id).fadeOut("fast",function(){
			$(document).unbind("mousedown", onBodyDown);
			$("#menuContent_" + id).empty();
			$("#menuContent_" + id).remove();
			$(contactor).siblings(".zTreeSelect .zTreeSelect-arrow").removeClass("arrow-up").addClass("arrow-down");
		});
	} else {
		if ($(".zTreeSelect-text").length > 0) {
			for (var i = 0; i < $(".zTreeSelect-text").length; i++) {
				var id = $(".zTreeSelect-text")[i].id;
				$.fn.zTree.destroy("treeDemo_" + id);//销毁树结构
			}
		}
		$(".zTreeSelect-menuContent").fadeOut("fast",function(){
			$(document).unbind("mousedown", onBodyDown);
			$(".zTreeSelect-menuContent").empty();
			$(".zTreeSelect-menuContent").remove();
			$(".zTreeSelect .zTreeSelect-arrow").removeClass("arrow-up").addClass("arrow-down");
		});
	}
}

/** 
 * 点击树形结构以外时，关闭树形下拉框
 * @param event
 */
function onBodyDown(event) {
	if (!($("#" + event.target.id).hasClass("zTreeSelect-arrow") || $("#" + event.target.id).hasClass("zTreeSelect-menuContent") || $(event.target).parents(".zTreeSelect-menuContent").length > 0)) {
		hideMenu();//隐藏树形结构
	}
	//alert($(event).hasClass("zTreeSelect-menuContent"));
	//if (!(event.target.id == "menuBtn" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length > 0)) {
	//	hideMenu();//隐藏树形结构
	//}
}

/** 
 * 搜索树节点事件
 * @param event
 */
var hideNodes=[];
function searchNode(event) {
	/*var treeId = $(this).siblings(".ztree")[0].id;
	var bindObjId = treeId.split("_")[1];
	var treeObj = $.fn.zTree.getZTreeObj(treeId);
	var keyType = $("#" + bindObjId).parent(".zTreeSelect").attr("zTreeSelect-search-field");
	var value = $.trim($(this).val());
	var zTreeNodes = treeObj.transformToArray(treeObj.getNodes());//所有集合对象
	for (var i = 0; i < zTreeNodes.length; i++) {
		zTreeNodes[i].highlight = false;
		treeObj.updateNode(zTreeNodes[i]);


	}
	if (value != "") {
		var nodeList = treeObj.getNodesByParamFuzzy(keyType, value);
		for (var i = 0; i < nodeList.length; i++ ) {
			nodeList[i].highlight = true;
			treeObj.updateNode(nodeList[i]);
		}
	}*/
    //console.log(nodeList);

    var treeId = $(this).siblings(".ztree")[0].id;
    var treeObj = $.fn.zTree.getZTreeObj(treeId);
    var bindObjId = treeId.split("_")[1];
    var allNode = treeObj.transformToArray(treeObj.getNodes());
    var keyType = $("#" + bindObjId).parent(".zTreeSelect").attr("zTreeSelect-search-field");
    var zTreeNodes = treeObj.transformToArray(treeObj.getNodes());//所有集合对象
    var value = $.trim($(this).val());
    treeObj.hideNodes(allNode);

    nodeList = treeObj.getNodesByParamFuzzy(keyType, value);//使用节点的name作为查询参数
    nodeList = treeObj.transformToArray(nodeList);
    for(var n in nodeList){
        findParent(treeObj,nodeList[n]);
        nodeList[n].highlight = true;
    }
    for (var i = 0; i < zTreeNodes.length; i++) {
        zTreeNodes[i].highlight = false;
        treeObj.updateNode(zTreeNodes[i]);


    }
    treeObj.showNodes(nodeList);
    if (value == "") {
        treeObj.expandAll(false);
    }
    if (value != "") {
        var nodeList = treeObj.getNodesByParamFuzzy(keyType, value);
        for (var i = 0; i < nodeList.length; i++ ) {
            nodeList[i].highlight = true;
            treeObj.updateNode(nodeList[i]);
        }
    }

    function findParent(treeObj,node){
        treeObj.expandNode(node,true,false,false);
        var pNode = node.getParentNode();
        if(pNode != null){ //递归得到指定节点的父节点的父节点....直到根节点
            nodeList.push(pNode);
            findParent(treeObj,pNode);
        }
    }
}





$(window).resize(function() {
	if ($(".zTreeSelect-menuContent").length > 0) {
		$(".zTreeSelect-menuContent").each(function(index, n) {
			var zTreeSelectText = $(n).prev(".zTreeSelect");
			var textObjOffset = $(zTreeSelectText).offset();
			
			$(n).find(".zTreeSelect-menuSearch").css({ width: ($(zTreeSelectText).width() - 12) + "px" });
			var zTreeSelectPosition = $(zTreeSelectText).attr("zTreeSelect-position");//设置下拉选择项是否要浮动
			var positionCss = "absolute", topCss = textObjOffset.top + zTreeSelectText.outerHeight + "px";
			if ((/^true$/i).test(zTreeSelectPosition)) {
				positionCss = "fixed";
				topCss = "auto";
			}
			$(n).css({
				width: $(zTreeSelectText).width() +"px",
				position: positionCss,
				top: topCss,
				left: (textObjOffset.left - 1) + "px"
			});
		});
	}
});